import pytest

from page.page_in import PageIn
from tools.get_driver import GetDriver
from tools.get_log import GetLog
from tools.read_yaml import read_yaml

logger = GetLog.get_logger()


class TestZoSearchCheck:
    # 1.初始化
    def setup_class(self):
        driver = GetDriver.get_app_driver()
        self.zoPageSearchCheck = PageIn(driver).page_get_ZoPageSearchCheck()

    # 2.结束
    def teardown_class(self):
        GetDriver.quit_app_driver()

    # 3.转业务方法
    @pytest.mark.parametrize('click_text, title', read_yaml('app_zo_search.yaml'))
    def test_zo_search_check(self, click_text, title):
        try:
            # 调用全局搜索业务方法
            assert self.zoPageSearchCheck.zo_page_search_check(click_text, title)
        except Exception as e:
            # 日志
            logger.error(e)
            # 截图
            self.zoPageSearchCheck.base_get_image()
            # 抛异常
            raise

